<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class RsTeamUser extends Model
{
    use HasFactory;
    public $timestamps=false;
    protected $table='rs_team_user';
    public function getUser(){
        return $this->hasOne(User::class,'id','user_id');
    }

    public function getRsUser(){
        return $this->hasOne(RsUsers::class,'user_id','user_id');
    }

    //创建数据
    public static function creates($data){
        if(!$data['id']){
            $model=new self();
            $model->user_id=$data['user_id'];
            $model->ramark=$data['remark'];
            $model->username=$data['username'];
        }else{
            $model=self::query()->where(['id'=>$data['id']])->first();
            $model->user_id=$data['user_id'];
            $model->username=$data['username'];
            $model->ramark=$data['remark'];
        }
        return $model->save() ?true:false;
    }
}
